package com.zhuss.controller.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.core.auth.AuthBo;
import com.zhuss.bean.bo.core.login.UpdatePwdBo;
import com.zhuss.bean.bo.core.login.wechat.BindBo;
import com.zhuss.bean.bo.core.login.wechat.RegisterBo;
import com.zhuss.bean.bo.core.login.wechat.UnbindBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.LoginOperateService;
import com.zhuss.core.login.LoginServiceApp;
import com.zhuss.exception.AabException;


/**
 * app
 * 登录操作 controller
 * @Author zhushanshuo
   @Date 2020-04-13 19:58
 *
 */
  
 
@RestController
@RequestMapping("/login")
public class LoginController extends BaseController {
	
	@Autowired
	@Qualifier("loginService")
	private LoginOperateService<Object, Object> loginService;
	
	@Autowired
	@Qualifier("loginServiceApp")
	private LoginServiceApp loginServiceApp;
	
	/**
	 * 一级菜单 
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/firstMenu")
    public Object firstMenu(@RequestBody AuthBo bo) throws AabException {
		
		Object result = loginServiceApp.firstMenu(bo);
		return result;
    }
	
	/**
	 * 
	 * 子级菜单 
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
	@PostMapping("/childMenu")
	public Object childMenu(@RequestBody AuthBo bo) throws AabException {
		
		Object result = loginServiceApp.childMenu(bo);
		return result;
	}
	
	/**
	 * 初始化 
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
	@PostMapping("/menu")
	public Object menu(@RequestBody AuthBo bo) throws AabException {
		
		Object result = loginServiceApp.menu(bo);
		return result;
	}
	
	/**
	 * 注册 
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/register")
    public void register(@RequestBody RegisterBo bo) throws AabException {
		
		loginServiceApp.register(bo);
    }
	
	/**
	 * 绑定
	 * 登录
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
	@PostMapping("/bind")
	public Object bind(@RequestBody BindBo bo) throws AabException {
		
		Object result = loginServiceApp.bind(bo);
		return result;
	}
	
	
	/**
	 * 解绑
	 * 登出
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/unbind")
    public void unbind(@RequestBody UnbindBo bo) throws AabException {
		
		loginServiceApp.unbind(bo);
    }
	
	/**
	 * 修改密码
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/pwdUpdate")
    public void pwdUpdate(@RequestBody UpdatePwdBo bo) throws AabException {
		
		loginServiceApp.updatePwd(bo);
    }

	
}
